const puppeteer = require('puppeteer')
const ora = require('ora')
// const fs = require('fs')
const path = require('path')

const htmlPath = 'file://' + path.join(__dirname, './dist/puppeteer.html')
console.log(htmlPath)
let headless = false
const executablePath = false


main()

async function main() {
    const spinner = ora()
    spinner.start('启动浏览器')
    let browser = await puppeteer.launch({headless: headless, executablePath: executablePath, defaultViewport: {width: 1920, height: 1080}, args: ['--window-size=1920,1080']})
    spinner.succeed('启动成功')
    let page = await browser.newPage()
    await page.goto(htmlPath)
    spinner.start('等待选择采集类型')
    await page.waitForFunction('document.querySelector("#result").value')
    spinner.succeed('选择完成')
    const result = await page.$eval('#result', el => el.value)
    console.log(result)
}